<?php

namespace app\api\controller;

use app\api\model\hotel\OrderCreate as OrderCreateModel;
use app\common\controller\Api;

class Hotelordercreate extends Api
{
    protected $noNeedRight = ['*'];


    //提交
    public function create()
    {
        try {
            $order_create_model = new OrderCreateModel();

            $data = [
                'user_id'=>$this->auth->id,
                'hotel_id'=>input('hotel_id',0),
                'room_num'=>input('room_num',1),
                'checkin_date'=>input('checkin_date',''),
                'checkout_date'=>input('checkout_date',''),
                'guest_name'=>input('guest_name',''),
                'phone'=>input('phone',''),
                'remark'=>input('remark',''),
                'room_type_code'=>input('room_type_code',''),
                'room_type_name'=>input('room_type_name',''),
                'coupon_id'=>input('user_coupon_id',0),
                'use_score'=>input('use_score',0),
            ];

            $res = $order_create_model->ordercreate($data);

        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }

    //计算
    public function calculate()
    {
        try {
            $order_create_model = new OrderCreateModel();

            $data = [
                'user_id'=>$this->auth->id,
                'hotel_id'=>input('hotel_id',0),
                'room_num'=>input('room_num',1),
                'checkin_date'=>input('checkin_date',''),
                'checkout_date'=>input('checkout_date',''),
                'coupon_id'=>input('user_coupon_id',0),
                'guest_name'=>input('guest_name',''),
                'phone'=>input('phone',''),
                'remark'=>input('remark',''),
                'room_type_code'=>input('room_type_code',''),
                'room_type_name'=>input('room_type_name',''),
                'use_score'=>input('use_score',0),
            ];

            $res = $order_create_model->calculate($data);

        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }


}